package lec09.pm;

import java.util.Vector;

public class QQ {
	final static long START_NUMBER = 10000;
	static int total = 0;
	Long number;
	String nickName;
	boolean isVip;
	Vector<QQ> friends;
	Vector<QQ> stranger;
	Vector<QQ> blackList;

	public QQ(String nickName) {
		number = START_NUMBER + total;
		this.nickName = nickName;
		isVip = false;
		friends = new Vector<QQ>();
		stranger = new Vector<QQ>();
		blackList = new Vector<QQ>();
		total++;
	}

	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer("QQInfo:");
		buffer.append("\nnumber=" + number);
		if (isVip)
			buffer.append("VIP");
		buffer.append("\nnickName=" + nickName);
		buffer.append("\nfriends:");
		for (QQ qq : friends)
			buffer.append(qq.number);
		if (stranger.isEmpty())
			buffer.append("\nstranger:" + stranger);
		if (blackList.isEmpty())
			buffer.append("\nblackList:" + blackList);
		return buffer.toString();
	}

	public boolean addFriend(QQ that) {
		if (that == this)
			return false;
		if (friends.contains(that))
			return false;
		this.friends.add(that);
		that.stranger.add(this);
		return true;

	}
}
